#import "GameController.h"
#import "GameScene.h"

@interface GameController (Private)
- (void) initGame;
@end

@implementation GameController (Private)
- (void) initGame
{
	gameScenes = [[NSMutableDictionary alloc] initWithCapacity:5];
	AbstractScene* scene = [[GameScene alloc] init];
	[gameScenes setValue:scene forKey:@"game"];
	currentScene = [gameScenes objectForKey:@"game"];
	
	
	[scene release];
	
}

@end




@implementation GameController
static GameController* sharedGameCtrl = nil;


- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration {}



-(void) updateSceneWithDelta:(float)delta
{
	[currentScene updateWithDelta:delta];
	
}



-(void) renderScene
{
	[currentScene render]; 
}




-(id)init {
	
	if (self = [super init]) {
		//init GameController
		currentScene = nil;
		[self initGame];
	}
	return self;
	
}

-(void)dealloc {
	
	[ super dealloc ];
	
}







+ (GameController*)sharedGameController
{
    if (sharedGameCtrl == nil) {
        sharedGameCtrl = [[super allocWithZone:NULL] init];
    }
    return sharedGameCtrl;
}


+ (id)allocWithZone:(NSZone *)zone {
    return [[self sharedGameController] retain];
}

- (id)copyWithZone:(NSZone *)zone {
    return self;
}

- (id)retain {
    return self;
}

- (NSUInteger)retainCount {
    return NSUIntegerMax;  //denotes an object that cannot be released
}

- (void)release {
    //do nothing
}

- (id)autorelease {
    return self;
}


@end
